def convert_currency(im, er):
    """
        汇率兑换函数
    """
    out = im * er
    return out

USD_VS_RMB = 6.77
while True:
    try:
        currency_str_value = input('请输入带单位的货币金额：')
        unit = currency_str_value[-3:]

        if unit not in ['USD','CNY'] :
            raise ValueError('不支持该种货币！')

        break

    except(ValueError,IndexError):
        print('请输入正确的带单位的货币金额！')

if unit == 'CNY':
    exchange_rate = 1 / USD_VS_RMB

elif unit == 'USD':
    exchange_rate = USD_VS_RMB

else:
    exchange_rate = -1

if exchange_rate != -1:
    in_money = eval(currency_str_value[:-3])
try:
    in_money = float(in_money)

except ValueError:
    print('请输入正确的带单位的货币金额！')
    in_money = 0

    out_money = convert_currency(in_money, exchange_rate)
    print('转换后的金额：', out_money)
